<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>享送小哥</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>

<body>
    <div id="data-loading">
        <div class="loading1"><img src="../images/loading.gif"></div>
    </div>
    <div class="vue">
        <ul class="order-l" v-if="orders.length>0">
            <li v-for="order in orders">
                <div class="order-t">寄件时间 {{order.create_time}}</div>
                <div class="order-box">
                    <div class="order-c1"><img src="../images/order1.png">
                        <h4>{{order.status_desc}}</h4>
                        <p>订单编号：{{order.order_sn}}</p>
                    </div>
                    <a href="javascript:;" class="order-c2">
                        <div class="order-cc">{{order.orderInfo.sender_address}}（{{order.orderInfo.sender_sub_address}}）</div>
                        <div class="order-cc order-cc1">{{order.orderInfo.consignee_address}}（{{order.orderInfo.consignee_sub_address}}）</div>
                    </a>
                    <div class="order-c3">
                        <div class="order-pay">￥{{order.pay_amount}}</div>
                        <a href="javascript:;" class="aui-btn aui-btn-info order-btn" v-if="order.status==0" @click="toOrder(order)">去支付</a>
                        <a href="javascript:;" class="aui-btn aui-btn-info order-btn" v-if="order.status>0" @click="toOrder(order)">详情</a>
                    </div>
                </div>
            </li>
        </ul>
        <div v-else style="text-align:center;margin-top:50px;color:#666;">没有订单!</div>
    </div>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/vue.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <script type="text/javascript">
        apiready = function() {

            api.setRefreshHeaderInfo({
                loadingImg: 'widget://image/refresh.png',
                bgColor: '#eee',
                textColor: '#333',
                textDown: '下拉刷新...',
                textUp: '松开刷新...'
            }, function(ret, err) {
                vObj.getOrderList(function() {
                    vObj.page = 1;
                    api.refreshHeaderLoadDone();
                });
            });

            api.addEventListener({
                name: 'scrolltobottom',
                extra: {
                    threshold: 0
                }
            }, function(ret, err) {
                vObj.page++;
                app.request.post('Client/cityOrders', {
                    page: vObj.page
                }, {}, function(res) {
                    if (res.code == 200) {
                        if (res.data.length > 0) {
                            for (var i = 0; i < res.data.length; i++) {
                                vObj.orders.push(res.data[i]);
                            }
                        } else {
                            app.error("没有更多了！");
                        }
                    } else {
                        app.error(res.message);
                    }
                });
            });

            vObj = new Vue({
                el: ".vue",
                data: {
                    orders: [],
                    page: 1
                },
                methods: {
                    toOrder: function(order) {
                        app.page({
                            name: 'order_detail0',
                            url: 'order_detail0.html',
                            pageParam: {
                                order: order
                            }
                        });
                    },
                    getOrderList: function(callback) {
                        app.request.post('Client/cityOrders', {}, {}, function(res) {
                            if (res.code == 200) {
                                vObj.orders = res.data;
                                app.request.finish(vObj);
                                callback && callback();
                            } else {
                                app.error(res.message);
                            }
                        });
                    }
                }
            });

            vObj.getOrderList();
        }
    </script>
</body>

</html>
